package com.zhaoyue.study.concurrency.thread;

import java.util.concurrent.TimeUnit;

/**
 * Created with IntelliJ IDEA.
 * User: zhaoyue
 * Date: 2016/8/30
 * Time: 16:51
 * 线程中断操作
 */
public class PrimeGenerator extends Thread{


    public void run() {
        super.run();
        while (true){
            System.out.println("111111");
            if(isInterrupted()){
                System.out.println("中断");
                return;
            }
        }
    }

    public static void main(String[] args) throws Exception{
        PrimeGenerator primeGenerator = new PrimeGenerator();
        primeGenerator.start();
        Thread.sleep(1000);
        primeGenerator.interrupt();//中断
    }
}
